Passed
Push — master ( 506943...0f9777 )
by Plamen
01:27
created

table_helper.LoadData.Run   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 17
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 21
rs 9.55
1
var table_helper = {
2
    IePrior: function(v){
3
        var rv = false;
4
        if(window.navigator.appName === 'Microsoft Internet Explorer'){
5
            var ua = window.navigator.userAgent;
6
            var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
7
            if(re.exec(ua) !== null){
8
                rv = parseFloat(RegExp.$1);
9
            }
10
            rv = rv < v ? true : false;
11
        }
12
        return rv;
13
    },
14
    GetParent: function(obj, objType){
15
        while(obj && obj.tagName !== objType.toUpperCase()){
16
            obj = obj.parentNode;
17
        }
18
        return obj;
19
    },
20
    ProcessPaginationLinks: function(tfoot){
21
        var pLinks = tfoot.querySelectorAll(".paging a");
22
        if(pLinks.length > 0){
23
            for(var j = 0; j < pLinks.length; j++){
24
                pLinks[j].setAttribute("href", "javascript:void(0);");
25
                pLinks[j].setAttribute("onclick", "return table.GoPage(this);");
26
            }
27
        }
28
    },
29
    RequestToUrl: function(rq){
30
        var url = location.pathname + ".json" + location.search;
31
        if(typeof rq === "object"){
32
            var getUrlVarName = {
33
                colNo: "col", colOrd: "ord", filter: "filter",
34
                filterBy: "filter-by", pageNo: "pg", exportType: "export",
35
                tableId: "table-id"
36
            };
37
            var flagFirst = location.search.length < 1 ? true : false;
38
            for(var r in rq){
1 ignored issue
show
Complexity introduced by
A for in loop automatically includes the property of any prototype object, consider checking the key using hasOwnProperty.

When iterating over the keys of an object, this includes not only the keys of the object, but also keys contained in the prototype of that object. It is generally a best practice to check for these keys specifically:

var someObject;
for (var key in someObject) {
    if ( ! someObject.hasOwnProperty(key)) {
        continue; // Skip keys from the prototype.
    }

    doSomethingWith(key);
}
Loading history...
39
                var clue = flagFirst === true ? "?" : "&";
40
                url += clue + getUrlVarName[r] + "=" + rq[r];
41
                flagFirst = false;
42
            }
43
        }
44
        return url;
45
    },
46
    RqObject: function(tableId){
47
        var rq = {};
48
        rq.tableId = tableId;
49
        rq.strDesc = this.strDesc;
50
        rq.strAsc = this.strAsc;
51
        return rq;
52
    }
53
};
54